#include"Channel.h"

struct Channel* ChannelInit(int fd, int event ,handleFunc readCallBack, handleFunc writeCallBack,handleFunc destoryCallBack,void* arg)
{
    struct Channel* channel = (struct Channel*)malloc(sizeof(struct Channel));
    channel->fd = fd;
    channel->event = event;
    channel->readCallBack = readCallBack;
    channel->writeCallBack = writeCallBack;
    channel->destoryCallBack = destoryCallBack;
    channel->arg = arg;
    return channel;
}

// 通过flag判断是否需要检测写事件
void updateWriteEvent(struct Channel* channel, bool flag)
{
    if(flag)
    {
        channel ->event =  channel ->event | WriteEvent;
    }else{
        channel ->event  = channel ->event & ~WriteEvent;
    }
}

bool isWriteEventEnable(struct Channel* channel)
{
    return channel->event & WriteEvent;
}

